package com.duoduo.springboot.shiro.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.duoduo.springboot.shiro.service.UserService;

/**
 * Shiro测试Controller
 *
 * @author 单红宇(365384722)
 * @myblog http://blog.csdn.net/catoop/
 * @create 2016年1月13日
 */
@Controller
@RequestMapping("/user")
public class UserController {

	private static final Logger logger = LoggerFactory.getLogger(UserController.class);
	@Autowired
	private UserService userService;

	@RequestMapping(value = { "", "/" }, method = RequestMethod.GET)
	public String getUserList(Model model) {
		model.addAttribute("userList", userService.listAll());
		return "user/user-list";
	}

	@RequestMapping("/edit/{userId}")
	public String getUserList(Model model, @PathVariable Integer userId) {
		logger.info("------进入用户信息修改-------");
		model.addAttribute("user", userService.getById(userId));
		return "user/user-form";
	}
}
